<template>
  <div>
    <el-card class="box-card">
      <div>
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm">
          <div class="div1">
            <img src="../../assets/LOGO/u20.png" width="40%" alt="" />
            <h1>TMS智慧物流</h1>
            <h1>系统管理后台</h1>
          </div>

          <el-form-item prop="account">
            <el-input
              v-model="ruleForm.account"
              placeholder="请输入账号"
            ></el-input>
          </el-form-item>

          <el-form-item prop="password">
            <el-input
              placeholder="请输入密码"
              v-model="ruleForm.password"
              show-password
            ></el-input>
          </el-form-item>

          <el-form-item>
            <el-button
              type="primary"
              style="
                width: 100%;
                background-color: #4fbd9b;
                border-color: #4fbd9b;
              "
              @click="submitForm('ruleForm')"
              >登录</el-button
            >
          </el-form-item>
          <el-alert title="账号或密码错误" v-show="messg" type="info" center show-icon>
          </el-alert>
        </el-form>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      ruleForm: {
        account: "",
        password: "",
      },
      rules: {
        account: [{ required: true, message: "请输入账号", trigger: "blur" }],
        password: [{ required: true, message: "请输入密码", trigger: "blur" }],
      },
      messg:false
    };
    
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$axios
            .get(
              "https://localhost:44360/api/app/t-mS_Operator/logan?account=" +
                this.ruleForm.account +
                "&password=" +
                this.ruleForm.password
            )
            .then((res) => {
              if (res.data.Code==200) {
                sessionStorage.setItem("id",res.data.Data.Id);
                this.$router.push("/kanban");
              } else {
                this.messg=true
              }
            });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
  },
};
</script>

<style>
.text {
  font-size: 14px;
}

.item {
  padding: 18px 0;
}

.box-card {
  margin-left: calc(calc(100vw - 400px) / 2);
  margin-top: 10%;
  width: 22%;
  height: 600px;
}
.div1 {
  color: #4fbd9b;
  text-align: center;
  margin-bottom: 18%;
}
</style>
